1 /* 2 * Copyright (c) 2014 Nonki Takahashi. All rights reserved. 3 * 4 * History: 5 * 0.3 2014-09-19 Method text is added. 6 * 0.2 2014-01-09 Interface changed and methods sq, sp are added. 7 * 0.1 2014-01-10 Created. 8 */ 9 10 /** 11 * @fileOverview Lex Specification - Lexical Analyzer Spec for Jasmine 12 * @version 0.3 13 * @author Nonki Takahashi 14 */ 15 16 describe("Lex 仕様 0.3", function() { 17 var exp = "1+2="; 18 var la; 19 20 beforeEach(function() { 21 la = new Lex(exp); // Lexical Analiser 22 }); 23 24 it("eod() は false を返す", function() { 25 expect(la.eod()).toBeFalsy(); 26 }); 27 28 it("digit() は '1' を返す", function() { 29 expect(la.digit()).toEqual('1'); 30 }); 31 32 it("upper() は null を返す", function() { 33 expect(la.upper()).toBe(null); 34 }); 35 36 it("lower() は null を返す", function() { 37 expect(la.lower()).toBe(null); 38 }); 39 40 it("sp() は null を返す", function() { 41 expect(la.sp()).toBeFalsy(); 42 }); 43 44 it("sq() は null を返す", function() { 45 expect(la.sq()).toBeFalsy(); 46 }); 47 48 it("ch('1') は '1' を返す", function() { 49 expect(la.ch('1')).toEqual('1'); 50 }); 51 52 it("text('1') は '1' を返す", function() { 53 expect(la.text('1')).toBe('1'); 54 }); 55 56 it("text('1+') は '1+' を返す", function() { 57 expect(la.text('1+')).toBe('1+'); 58 }); 59 60 it("text('2') は null を返す", function() { 61 expect(la.text('2')).toBe(null); 62 }); 63 64 describe("3文字読んだ時点で、", function() { 65 beforeEach(function() { 66 la.rewind(); 67 la.digit(); 68 la.ch('+'); 69 la.digit(); 70 }); 71 72 it("eod() は false を返す", function() { 73 expect(la.eod()).toBe(false); 74 }); 75 76 it("digit() は null を返す", function() { 77 expect(la.digit()).toBe(null); 78 }); 79 80 it("upper() は null を返す", function() { 81 expect(la.upper()).toBe(null); 82 }); 83 84 it("lower() は null を返す", function() { 85 expect(la.lower()).toEqual(null); 86 }); 87 88 it("ch('=') は '=' を返す", function() { 89 expect(la.ch('=')).toBe('='); 90 }); 91 92 }); 93 94 describe("4文字読んだ時点で、", function() { 95 beforeEach(function() { 96 la.rewind(); 97 la.digit(); 98 la.ch('+'); 99 la.digit(); 100 la.ch('='); 101 }); 102 103 it("eod() は true を返す", function() { 104 expect(la.eod()).toBeTruthy(); 105 }); 106 107 }); 108 109 }); 110